package controller

import (
	"github.com/e421083458/gorm"
	"github.com/gin-gonic/gin"
	"rock/customer/service/master"
)

//基础数据库
var InstanceDB *gorm.DB

//业务数据库
var BusinessDB *gorm.DB

func InitDB() {
	InstanceDB = service.InstanceDB
	BusinessDB = service.BusinessDB
}

var userService = &service.User{}
var robotService = &service.Robot{}
var groupService = &service.Group{}
var messageService = &service.Message{}
var serviceService = &service.Service{}
var customerServiceService = &service.CustomerService{}

type AddrBookController struct {
}

func RegisterAddrBookRouter(router *gin.RouterGroup) {
	this := &AddrBookController{}
	router.POST("/addrbooklist", this.addrBookList)
}

type ChatMessageController struct {
}

func RegisterChatMesssageRouter(router *gin.RouterGroup) {
	this := &ChatMessageController{}
	router.POST("/messageslist", func(context *gin.Context) {
		this.messagesList(context)
		//Ch <- context
	})
	router.POST("/messagescontent", this.messagesContent)
	router.POST("/invitationmessages", this.invitationMessages)
	router.POST("/syncmessage", this.synchronizeMessages)
	router.POST("/forwardmessages", this.forwardMessages)
	router.POST("/transfermessagesout", this.transferMessagesOut)
	router.POST("/transfermessagesin", this.transferMessagesIn)
	router.POST("/mergemessages", this.mergeMessages)
	router.POST("/customercoming", this.CustomerComing)
}

type GroupController struct {
}

func RegisterGroupRouter(router *gin.RouterGroup) {
	this := GroupController{}
	router.POST("/creategroup", this.createGroup)
	router.POST("/createcsgroup", this.createCsGroup)
	router.POST("/joingroup", this.joinGroup)
	router.POST("/quitgroup", this.quitGroup)
	router.POST("/dismissgroup", this.dismissGroup)
	router.POST("/querygroupmember", this.queryGroupMember)
	router.POST("/queryjoingroup", this.queryUserJoinGroup)
	router.POST("/changebrowsestatus", this.changeBrowseStatus)
	router.POST("/refreshgroup", this.refreshGroup)
	router.POST("/mgroupstate", this.modifyGroupState)
	router.POST("/checkcsgroup", this.checkCsGroup)
}

type RobotController struct {
}

func RegisterRobotRouter(router *gin.RouterGroup) {
	this := RobotController{}
	router.POST("/createrobot", this.createRobot)
	router.POST("/sendwelcomemsg", this.sendWelcomeMsg)
}

type RongCloudController struct {
}

func RegisterRongCloudRouter(router *gin.RouterGroup) {
	this := &RongCloudController{}
	router.POST("/rctoken", this.getRongCloudToken)
}

type AuthenticationController struct {
}

func RegisterAuthenticationRouter(router *gin.RouterGroup) {
	this := &AuthenticationController{}
	router.POST("/wechatlogin", this.wechatLogin)
	router.POST("/getwechatmobile", this.getWechatMobile)
	router.POST("/sendnoticemsg", this.sendNoticeMsg)
	router.POST("/generateurllink", this.generateUrlLink)
	router.POST("/wechatloginqrcode", this.weChatLoginQrCode)
}

type WkbUserController struct {
}

func RegisterWkbRouter(router *gin.RouterGroup) {
	this := WkbUserController{}
	//router.POST("/checkuser1", this.checkUser, timedHandler(3 * time.Second))
	router.POST("/checkuser", this.checkUser)
	router.POST("/telregister", this.telRegister)
	router.POST("/getuserdetail", this.getUserDetail)
	router.POST("/updatecustomerservice", this.updateCustomerService)
}

type TestController struct {
}

func RegisterTest(router *gin.RouterGroup) {
	this := TestController{}
	router.POST("/dismissallgroup", this.dismissAllGroup)
}

type PersonalCenterController struct {
}

func RegisterPersonalCenterControllerRouter(router *gin.RouterGroup) {
	this := PersonalCenterController{}
	router.POST("/modifyuser", this.modifyUserDetail)
	router.POST("/mypage", this.myPage)
	router.POST("/achievementlist", this.achievementList)
	router.POST("/modifyuseronline", this.modifyUserOnline)
}
